Skip to content

CDTOOL-1328 list version refactor#1774

Merged
anthony-gomez-fastly merged 6 commits intomainfrom
rcaril/CDTOOL-1328-list-version-refactor
May 8, 2026
Merged

CDTOOL-1328 list version refactor#1774
anthony-gomez-fastly merged 6 commits intomainfrom
rcaril/CDTOOL-1328-list-version-refactor

Conversation

@anthony-gomez-fastly
Copy link
Copy Markdown
Member

@anthony-gomez-fastly anthony-gomez-fastly commented May 5, 2026

Change summary

Performance Optimization - Skip ListVersions API call for numeric versions

Changes to pkg/argparser/flags.go:

  1. OptionalServiceVersion.Parse() - Skip API call for numeric versions
    - Added early return when user provides numeric version (e.g., --version 1)
    - Returns &fastly.Version{Number: n} directly without calling ListVersions API
    - Saves 1 API call per command when numeric version is used
    - Non-numeric versions (e.g., "latest", "active") still call API as before
  2. OptionalAutoClone.Parse() - Handle unknown version state
    - Added stateUnknown check: v.Active == nil && v.Locked == nil
    - Updated autoclone condition to include stateUnknown case
    - Effect: When --autoclone is provided with numeric version, always clones (defensive behavior) since state is unknown
    - Maintains safety while benefiting from optimization

Changes to pkg/argparser/flags_test.go:

  • Updated test "specific version not in list" - now expects success (version 5) instead of error
  • Added explicit Active/Locked fields to "version is editable" test

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?

New Feature Submissions:

  • Does your submission pass tests?

Changes to Core Features:

  • Have you written new tests for your core changes, as applicable?
  • Have you successfully run tests with your changes locally?

@anthony-gomez-fastly anthony-gomez-fastly force-pushed the rcaril/CDTOOL-1328-list-version-refactor branch 5 times, most recently from a740a16 to 429df46 Compare May 7, 2026 18:29
…e specific service version filter API calls

Co-Authored-By: Richard Carillo <77027245+rcaril@users.noreply.github.com>
@anthony-gomez-fastly anthony-gomez-fastly force-pushed the rcaril/CDTOOL-1328-list-version-refactor branch from 429df46 to 0c76483 Compare May 7, 2026 18:40
@anthony-gomez-fastly anthony-gomez-fastly marked this pull request as ready for review May 7, 2026 18:51
@anthony-gomez-fastly anthony-gomez-fastly requested a review from a team as a code owner May 7, 2026 18:51
Comment thread pkg/argparser/flags.go
Comment thread pkg/argparser/flags.go
@anthony-gomez-fastly
Copy link
Copy Markdown
Member Author

most of the changes are updating the tests to use the right mock

Copy link
Copy Markdown
Member

@rcaril rcaril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor points - but the PR is good to go as is if you would like to defer these. Thanks for all of your hard work on this @anthony-gomez-fastly !

Comment thread pkg/argparser/flags.go
Comment thread pkg/commands/service/resourcelink/resourcelink_test.go Outdated
Copy link
Copy Markdown
Member

@kpfleming kpfleming left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I agree this looks great. I thought we had already added --version=staged but I guess we never did!

@anthony-gomez-fastly
Copy link
Copy Markdown
Member Author

@kpfleming added staging!

@anthony-gomez-fastly anthony-gomez-fastly merged commit 576f624 into main May 8, 2026
13 checks passed
@anthony-gomez-fastly anthony-gomez-fastly deleted the rcaril/CDTOOL-1328-list-version-refactor branch May 8, 2026 13:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants